package com.itheima.d2_list;

import java.util.LinkedList;

/**
 * LinkedList模拟队列 栈数据结构
 */
public class ListDemo2 {
    public static void main(String[] args) {
        //模拟队列
        LinkedList<String> queue = new LinkedList<>();
        //入队
        queue.addLast("宁姚");
        queue.addLast("李宝瓶");
        queue.addLast("阮秀");
        queue.addLast("贺小凉");
        //出队
        System.out.println(queue.removeFirst());
        System.out.println(queue.removeFirst());
        System.out.println(queue.removeFirst());
        System.out.println(queue.removeFirst());
        System.out.println(queue);

        //模拟栈
        LinkedList<String> stack = new LinkedList<>();
        //进栈
        stack.addFirst("宁姚");
        stack.addFirst("李宝瓶");
        stack.addFirst("阮秀");
        System.out.println(stack);

        //出栈
        System.out.println(stack.removeFirst());
        System.out.println(stack.removeFirst());
        System.out.println(stack.removeFirst());


    }
}
